Skip to content

Maintain compatibility with CPython 3.13 #1242

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

daskol
Copy link

@daskol daskol commented Mar 27, 2025

See changes in Python C API in CPython 3.13 changelog. Initial discussion is in AUR.

@medaminezghal
Copy link

medaminezghal commented Mar 28, 2025

@daskol You need to edit the files that use asyncore (Removed in python 3.13) to make it use asyncio
This what I did in the prepare function in PKGBUILD file:

    sed -i 's/_try_asyncore_import/_try_asyncio_import/g' cassandra/cluster.py
    sed -i 's/from cassandra.io.asyncorereactor import AsyncoreConnection/from cassandra.io.asyncioreactor import AsyncioConnection/g' cassandra/cluster.py
    sed -i 's/from cassandra.io.asyncorereactor import AsyncoreConnection/from cassandra.io.asyncioreactor import AsyncioConnection/g' tests/integration/long/test_ipv6.py
    sed -i 's/(AsyncoreConnection,None)/(AsyncioConnection,None)/g' cassandra/cluster.py
    sed -i '/import asynctest/d' tests/unit/io/test_asyncioreactor.py
    sed -i 's/asynctest.TestSelector()/AsyncMock()/g' tests/unit/io/test_asyncioreactor.py
    sed -i '/from unittest.mock import patch/a from unittest.mock import AsyncMock' tests/unit/io/test_asyncioreactor.py

Maybe be you could edit the files to use asyncore or asyncio by case (python>=3.13 or not)

@medaminezghal
Copy link

@daskol and even after I edit for some reason I can't import the cassandra.io.libevwrapper

@daskol
Copy link
Author

daskol commented Mar 28, 2025

@medaminezghal What about cqlsh utility? It does not work without this fix because of missing cp313 wheels.

@medaminezghal
Copy link

@daskol if you build the package without the C extensions it should work (of course after editing the files that use asyncore) and then you can build cqlsh in python 3.13

@medaminezghal
Copy link

medaminezghal commented Mar 28, 2025

@daskol you can replace any code that use asyncore with asyncio safely https://docs.python.org/3/library/asyncore.html

@daskol
Copy link
Author

daskol commented Mar 28, 2025

Do pacman -S python-pyasyncore or pip install pyasyncore solve your issue? Initially, I faced with the issue of missing cp313 wheels and build failure of this dreiver from scratch.

@medaminezghal
Copy link

I think it’s not useful to use unmaintained package as provided in the description. So it’s better to use asyncio

@medaminezghal
Copy link

@daskol I think you need to fix the problem related to this issue from other project.
There is only 1 file that use asynctest package.
Also the distutils (used to build the C extensions) is deprecated and will be removed soon.

@absurdfarce
Copy link
Collaborator

Thanks for the PR @daskol!

Have you signed the Contributor License Agreement for contributions to DataStax open source projects? If not you can find it at https://cla.datastax.com/. Thanks!

I mentioned this in another recently submitted PR but it's worth restating here: because the Python driver aims to support all Python runtimes that aren't end-of-life we still have to support Python 3.9.x and up. And since the asyncore reactor is more stable than the current asyncio version I have no plans to remove it anytime soon. There's a lot more detail in my comment.

For the record: if you want to use the libev reactor you'll need libev installed and accessible via the lib path before the Python driver will even attempt to use it. You can find some additional info in our docs on installing the Python driver.

@daskol
Copy link
Author

daskol commented May 28, 2025

@absurdfarce Yes, I signed agreement as soon as you posted this requirement in #1244.

we still have to support Python 3.9.x and up.

This PR exactly improves support for CPython 3.9+.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants